<!doctype html>
<html>
  <head>
    <title>改变html元素</title>
    <meta charset="utf-8">
  </head>
  <body>
    
    <p name='p1-name' id="p1">你好，世界！</p>
    
    <script>
      //通过元素id改变元素内容
      //document.getElementById('p1').innerHTML = '你好，JavaScript!-ById';
      
      //通过元素name改变元素内容
      //var pList = document.getElementsByName('p1-name');
      //if(pList.length > 0) {
      //  pList[0].innerHTML = '你好，JavaScript-ByName';
      //}

      //通过元素标签改变元素内容
      var pList = document.getElementsByTagName('p');
      if(pList.length > 0) {
        pList[0].innerHTML = '你好，JavaScript-ByTagName';
      }
      
    </script>
  </body>
</html>